/****************************************************************************/
/* Batch System Management with performance prediction: OAR v2.x            */
/*                                                                          */
/* Author(s):                                                               */
/*    - Yves Caniou (yves.caniou@ens-lyon.fr)                               */
/*    - Jonathan Amiez (jonathan.amiez@gmail.com)                           */
/*                                                                          */
/* $LICENSE$                                                                */
/****************************************************************************/

#ifndef _OAR2_xBATCH_SYSTEM_HH_
#define _OAR2_xBATCH_SYSTEM_HH_

#include "BatchSystem.hh"

class OAR2_xBatchSystem : public BatchSystem
{
  
public :

  OAR2_xBatchSystem(int batchID, const char * batchName) ;

  ~OAR2_xBatchSystem() ;

  /** If job not terminated, ask the batch system for the status of job
      whose ID is @param batchJobID .
      Updates the internal structure.
      Returns NB_STATUS on error, the status otherwise.
  */
  batchJobState
  askBatchJobStatus(int batchJobID) ;
  
  /** If job whose id is @param batchJobID is:
      - not finished, returns 0
      - terminated, returns 1
      - not found, -1
  */
  int
  isBatchJobCompleted(int batchJobID) ;

  /************************ Submitting Funtions *******************/
  /* This function overrides the one defined in BatchSystem.hh.
   * It must be re-defined because OAR 2.x script directives are not
   * compatible with other batch systems. */

  int
  diet_submit_parallel(diet_profile_t * profile,
		       const char * command,
		       const char * user_batch_cmd);

  /********** Batch static information accessing Functions **********/
  /* These should soon change for they assume a default queue and we
     want to be able to manage all queues of a system! */

  int
  getNbTotResources() ;

  int
  getNbResources() ;

  char *
  getResourcesName() ;
  
  int
  getMaxWalltime() ;

  int
  getMaxProcs() ;
  
  /********** Batch dynamic information accessing Functions *********/
  /* These should soon change for they assume a default queue and we
     want to be able to manage all queues of a system! */

  int
  getNbTotFreeResources() ;

  int
  getNbFreeResources() ;

  /****************** Performance Prediction Functions ***************/

  char*
  getLoad( ) ;

private :
  /* Dirty Trick for OAR1.6 to get information on default queue */
  const char * internQueueName ;

  /* Strings used to filter batch job status if possible */
  static const char * const statusNames[] ;

} ;

#endif // OAR_BATCH_SYSTEM
